<?php
/**
 * Created by PhpStorm.
 * User: minicart
 * Date: 2018/12/2
 * Time: 12:16
 */
namespace app\models;

use think\Model;

/**
 * Class TeacherModel
 * @package app\models
 */
class CapitalAllocationRecordModel extends Model
{
    protected $table = 'edu_capital_allocation_record';

    /**
     * @param $param
     * @return array
     * @throws \think\exception\DbException
     */
    public function getCapitalAllocationRecordLists($param)
    {
        $page = isset($param['page']) ? (int) $param['page'] : 1;
        $listRows = isset($param['limit']) ? (int) $param['limit'] : 10;
        $where = [];
        if (isset($param['contracted_name']) && '' !== $param['contracted_name']) {
            $where['contracted_name'] = ['like', $param['contracted_name'].'%'];
        }

        $listData = self::where($where)
            ->paginate($listRows, false, ['page' => $page])
            ->toArray();
        if (!empty($listData)) {
            foreach ($listData['data'] as &$item) {;
                  if($item['type'] == 1){
                      $item['type'] = "资金回抽";
                  }else if($item['type'] == 2){
                      $item['type'] = "资金分配";
                  }

                  $item['allotted_quantity'] =  $item['allotted_quantity'].'(课时)';
                  $item['allocation_allotted'] =  $item['allocation_allotted'] / 100;

            }
        }
        return $listData;
    }


}